package datasv.framework_datasv;

import data.datafactory.DatabaseOperator;
import resultmessage.FrameworkRM;

public class DeleteModel {
	public static void main(String[] args) {
		System.out.println(new DeleteModel().deleteModel("001", "0010102"));
	}
	public FrameworkRM  deleteModel(String collegeID,String modelID){
		return deleteInSql(collegeID, modelID);
	}
	private FrameworkRM deleteInSql(String collegeID,String modelID){
		DatabaseOperator op=new DatabaseOperator("college"+collegeID);
		if(!op.ifDatabaseExist()){
			return FrameworkRM.COLLEGEID_NOT_EXIST;
		}
		if(!op.ifIDExist("plan_model_list", modelID)){
			return FrameworkRM.MODELID_NOT_EXIST;
		}
		if(!op.deleteOneRow(modelID, "plan_model_list")){
			return FrameworkRM.MODELID_NOT_EXIST;
		}
		if(!op.deleteForm("plan_submodel_list_"+modelID)){
			return FrameworkRM.MODELID_NOT_EXIST;
		}
		return FrameworkRM.SUCCESS;
	}
}

